package com.example.neteasecloudmusicapilearningproject.ktvDemo;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.neteasecloudmusicapilearningproject.R;

import java.util.ArrayList;
import java.util.List;

public class RecyclerActivity extends AppCompatActivity {
    private List<News> Recycler = new ArrayList<>();
    RecyclerView recyclerView;
    GridLayoutManager gridLayoutManager;
    RecyclerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ktv);
        initApp();
        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        gridLayoutManager = new GridLayoutManager(this,3){
            @Override
            public boolean canScrollVertically() {
                return false;
            }

        };
        recyclerView.setLayoutManager(gridLayoutManager);
        adapter = new RecyclerAdapter(Recycler);
        recyclerView.setAdapter(adapter);
    }

    private void initApp() {
        for (int i = 0; i < 3; i++) {
            News apple = new News("App", R.drawable.welcome_3);
            Recycler.add(apple);
        }
    }
}